<?php 
# 文件名称:config.view.php
# MetInfo在线反馈系统 
# Copyright (C) 长沙米拓信息技术有限公司 (http://www.metinfo.cn). All rights reserved.
class configView extends C_view
{
	function configView()
	{
		parent::C_view();
	}
	//加载模板
	function display($tpl)
	{		
		$SYS = &get_instance();
		$row = &$SYS->config;
		$class = $SYS->request->getVar('option', '', 'get');
		$class = $class==''?$SYS->request->getvar('option') : $class;
		$switch = array('','','');
		//加载js库
		$SYS->html->script('switcher.js');
		$js_content="			
			window.addEvent('domready', function() {
			$$('.hasTip').each(function(el) {
				var title = el.get('title');
				var parts = title.split('::', 2);
				el.store('tip:title', parts[0]);
				el.store('tip:text', parts[1]);
			});
			var JTooltips = new Tips($$('.hasTip'), { maxTitleChars: 50, fixed: false});
		});
		window.addEvent('domready', function(){ 
				new Accordion($$('.pane-toggler'), 
				$$('.pane-slider'), 
				{
					onActive: function(toggler, i) 
					{ 
						toggler.addClass('pane-toggler-down');toggler.removeClass('pane-toggler'); 
					},
					onBackground: function(toggler, i) 
					{ 
						toggler.addClass('pane-toggler'); toggler.removeClass('pane-toggler-down'); 
					},
					duration: 300,opacity: false,alwaysHide: true
				}); 
			});
		";
		$SYS->doc->addScriptDeclaration($js_content);
		$SYS->html->script('core.js');
		$SYS->html->script('mootools-more.js');
		switch($class)
		{
			case 'site':$switch[0]='class="active"';break;
			case 'system':$switch[1]='class="active"';break;
			case 'server':$switch[2]='class="active"';break;
			default:$switch[0]='class="active"';break;
		}
		$lists 	= array ();
		//网站配置
		$lists['offline'] = C_HTML::_('select.booleanlist', 'config[offline]', 'class="inputbox"', $row->item('offline'));
		//系统配置
		$lists['activation'] = C_HTML::_('select.booleanlist', 'config[activation]', 'class="inputbox"', $row->item('activation'));
		$lists['caching'] = C_HTML::_('select.booleanlist', 'config[caching]', 'class="inputbox"', $row->item('caching'));
		$this->assignRef( 'title', C_text::_('site configuration'));
		$this->assignRef('row',	$row);
		$this->assignRef('lists',	$lists);		
		$this->assignRef('switch', $switch);
		$themes = C_html::_('select.genericlist',   $this->getThemes(), 'config[sitetheme]', ' class="inputbox"', 'value', 'text', $row->item('sitetheme') );
		$this->assignRef( 'themes', $themes);
		$this->assignRef('itemfield', $this->getItemfield());
		$this->assignRef('message', $SYS->loader->getMessageQueue());
		parent::display();
	}
	//网站标题多语言
	function getItemfield()
	{
		$db = C_loader::getDBO();
		$query = 'SELECT b.id,b.fieldvalue,c.`default`,c.id langid'.
				' FROM '.$db->_table_prefix.'fields'.' AS b '.
				' ,'.$db->_table_prefix.'language'.' AS c '.
				' WHERE b.recordid=0'.
				' AND b.module=0'.
				' AND b.lang=c.id'.
				' AND b.fieldname="sitename"'.
				' ORDER BY c.`backend` desc,langid'
		;		
		$db->setQuery($query);		
		$this->_itemfield = $db->loadAssocList();
		return $this->_itemfield;
	}
	//网站的主题风格
	function getThemes()
	{
		$path = PATH_SITE.DS.'templates'.DS.'sites';
		//目录	
		$fso    =   opendir($path);
		$result = 	array();
		if($fso)
		{
			while($file=readdir($fso))
			{
				if($file!='.' && $file!='..')
				{			
					$filepath=$path.DS.$file;
					//处理目录
					if(is_dir($filepath)) 
					{											
						$result[] = C_html::_('select.option',  $file, $file);						
					}					
				}				
			}
		}
		return $result;
	}
}
# 本程序是一个开源系统,使用时请你仔细阅读使用协议,商业用途请自觉购买商业授权.
# Copyright (C) 长沙米拓信息技术有限公司 (http://www.metinfo.cn). All rights reserved.
?>